package com.alibaba.aone.casestudy.job;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.aone.casestudy.service.CasestudyService;
import com.alibaba.aone.casestudy.common.entity.Casestudy;
import com.alibaba.aone.casestudy.common.utils.MessageUtil;

/**
 * 类CasestudyJob.java的实现描述：TODO 类实现描述 
 * @author yongchun.chengyc 2011-5-5 上午10:22:11
 */


public class CasestudyJob {

	@Autowired
	private CasestudyService casestudyService;
	
	
	
	
	public void job() {
	List<Casestudy> casestudies = casestudyService.getAllCasestudies();
	
	for(Casestudy casestudy:casestudies){
		//获得casestudy的发起人
		String initiator = casestudy.getInitiator();
		//获得casestudy的分析日期
		Timestamp analysisTime = casestudy.getGmtAnalysisDate();
		
		//获得casestudy的状态
		int status = casestudy.getStatus();
		//获得当前时间
		Timestamp now = new Timestamp(System.currentTimeMillis());
		
		//时间差
		int timeDiff = (int) ((now.getTime()-analysisTime.getTime())/1000/60/60/24);
		
		if(status==1){
			if(null!=analysisTime){
				if((timeDiff<=2)&&(timeDiff>=0)){

					String message = initiator + " ,请尽快完成您的《--"
							+ casestudy.getNumber() + "--》并提交"+casestudy.getChecker()+"审核";
					MessageUtil.sendWangwangMessage(initiator, message);
					System.out.println(initiator + " ,请尽快完成您的《--"
							+ casestudy.getNumber() + "--》并提交"+casestudy.getChecker()+"审核");
				}
				
			}
		}
		
	}
}
}
